<?php

class SF_Autocoupon_NewController extends Mage_Core_Controller_Front_Action 
{ 
   
    /**
     *email 邮箱
     *events_code  活动编码 
     *rule_id  规则id
     */
    public function sendEmailCouponAction(){        
        $post_data= $this->getRequest()->getPost();
        $couponglog_model = Mage::getModel("autocoupon/couponlog")
          ->setEmail($post_data['email'])
          ->setRuleId($post_data['rule_id'])
          ->setEventsCode($post_data['events_code']);

        if($couponglog_model->sendActiveCoupon()){
            echo json_encode("success");
        }else{
            echo json_encode("error");
        }
    }
    public function sweepstakesAction(){
        $post_data= $this->getRequest()->getPost();
        $couponglog_model = Mage::getModel("autocoupon/lotterycode")
            ->setEmail($post_data['email'])
            ->setEventsCode($post_data['events_code']);
       
        if($couponglog_model->sendActiveCoupon()){
            echo json_encode("success");
        }else{
            echo json_encode("error");
        }
    }
}
